<?php

namespace app\admin\model\agent;

use think\Model;


class Agent extends Model
{





    // 表名
    protected $name = 'agent';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [

    ];
    /**
     * 代理升级
     */
    public static function crontabUp($user,$list)
    {
        if($user->agent>=count($list)){
            return true;
        }
        foreach ($list as $ks=>$vs){
            if($user->agent>$vs['id']){
                continue;
            }
            if($user->zhiNum>=$vs['zhi']){
                $user->agent = $vs['id'];
                $user->save();
            }
        }
        return true;
    }






}
